package com.shunda.ysdgj.manager.controller;

import com.shunda.ysdgj.manager.service.UploadService;
import com.shunda.ysdgj.model.dto.FileDto;
import com.shunda.ysdgj.model.vo.ResultVo;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/admin/upload")
@RequiredArgsConstructor
public class UploadController {

    private final UploadService uploadService;

    @Operation(summary = "上传图片")
    @PostMapping("picture")
    public ResultVo picture(MultipartFile file, @RequestParam String usage) {
        return ResultVo.success(uploadService.uploadPicture(usage, file));
    }

    @Operation(summary = "删除上传的文件")
    @PostMapping("remove")
    public ResultVo remove(@RequestBody FileDto fileDto) {
        uploadService.removeFiles(fileDto);
        return ResultVo.success();
    }

}
